#include <iostream>
#include <stack>

using namespace std;

const int N = 110;

bool st[N]; // st[i]标记是否已经匹配

int main()
{
	string s; cin >> s;

	stack<int> stk; // 里面存的是左括号的下标
	for(int i = 0; i < s.size(); i++)
	{
		char ch = s[i];
		if(ch == '(' || ch == '[') stk.push(i);
		else 
		{
			//右括号
			if(stk.empty()) continue;

			int t = stk.top(); 
			char left = s[t];
			if((left == '(' && ch == ')') || (left == '[' && ch == ']'))
			{
				st[t] = st[i] = true;
				stk.pop();
			}
		}
	}

	//还原字符串
	string ret = "";
	for(int i = 0; i < s.size(); i++)
	{
		if(st[i]) ret += s[i];
		else 
		{
			if(s[i] == '(' || s[i] == ')') ret += "()";
			else ret += "[]";
		}
	}
	cout << ret << endl;

	return 0;
}